﻿<%@ Page Title="" Language="C#" MasterPageFile="~/QLBH.Master" AutoEventWireup="true" CodeBehind="NguoiDung.aspx.cs" Inherits="Quanly.NguoiDung" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphHeader" runat="server">
     <telerik:RadCodeBlock runat="server">
         <script type="text/javascript">
             function delUser(username,status) {
                 var msg = status == "1" ? "khóa" : "mở khóa";
                 return confirm("Bạn có muốn " + msg + " người dùng: " + username + "?");
             }
         </script>
     </telerik:RadCodeBlock>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="margin: 0 auto"><h3 style="text-align: center">DANH SÁCH NGƯỜI DÙNG</h3></div>
    <div style=" margin: 0 auto; margin: 10px 0 0 20px;">
        <a href="/ThemNguoiDung.aspx" class="btn btn-primary">Thêm người dùng</a>
    </div>
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="False" Skin="Metro"  />
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <div style=" margin: 0 auto; margin: 10px 20px 0 20px;">
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
        <telerik:RadGrid runat="server" ID="gridUser" AutoGenerateColumns="False" AllowCustomPaging="True" AllowPaging="True" AllowSorting="True" 
                         Width="100%" EnableLinqExpressions="True"
                         AllowFilteringByColumn="True" PageSize="20" ShowGroupPanel="True" OnItemDataBound="gridUser_ItemDataBound" Skin="Metro"
                         OnItemCommand="gridUser_ItemCommand" OnNeedDataSource="gridUser_NeedDataSource">
            <HeaderStyle HorizontalAlign="Left" Font-Bold="True" />
            <MasterTableView UseAllDataFields="False" GridLines="None" Width="100%" AllowMultiColumnSorting="True">
                <Columns>
                    <telerik:GridBoundColumn  HeaderText="Họ và tên"  DataField="FullName"   Groupable="False" HtmlEncode="True"
                                              FilterControlWidth="120px" AndCurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="False" UniqueName="FullName">
                        <HeaderStyle Width="100px"></HeaderStyle>
                        <ItemStyle Width="100px"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Số điện thoại" DataField="Phone" FilterControlWidth="110px" AndCurrentFilterFunction="Contains" UniqueName="Phone"
                                                ShowFilterIcon="false" AutoPostBackOnFilter="true" Groupable="False" HtmlEncode="True">
                        <HeaderStyle Width="100px"></HeaderStyle>
                        <ItemStyle Width="100px"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn  HeaderText="Email"  DataField="Email"   Groupable="False" HtmlEncode="True"
                                              FilterControlWidth="120px" AndCurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="False" UniqueName="Email">
                        <HeaderStyle Width="100px"></HeaderStyle>
                        <ItemStyle Width="100px"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn  HeaderText="Username"  DataField="Username"   Groupable="False" HtmlEncode="True"
                                              FilterControlWidth="120px" AndCurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="False" UniqueName="Username">
                        <HeaderStyle Width="100px"></HeaderStyle>
                        <ItemStyle Width="100px"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn  HeaderText="ExtraInfo"  DataField="ExtraInfo" AllowSorting="False"  Groupable="False" HtmlEncode="True" UniqueName="ExtraInfo" AllowFiltering="False">
                        <HeaderStyle Width="200px"></HeaderStyle>
                        <ItemStyle Width="200px"></ItemStyle>
                    </telerik:GridBoundColumn>
                   <telerik:GridDateTimeColumn FilterControlWidth="110px" DataField="LastLogin" HeaderText="LastLogin"  ShowFilterIcon="False" UniqueName="LastLogin" DataFormatString="{0:g}"
                                                PickerType="DatePicker" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" Groupable="False" EnableTimeIndependentFiltering="True">
                        <HeaderStyle Width="100px"></HeaderStyle>
                    </telerik:GridDateTimeColumn>
                     <telerik:GridBoundColumn HeaderText="Tình trạng" DataField="Status" Groupable="False" AllowFiltering="False" UniqueName="Status">
                        <HeaderStyle Width="60px"></HeaderStyle>
                        <ItemStyle Width="60px"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn Groupable="False" AllowFiltering="False">
                        <HeaderStyle Width="100px"></HeaderStyle>
                        <ItemTemplate>
                            <div style="width: 120px">
                                <a class="glyphicon glyphicon-pencil" runat="server" id="aEdit" title="Sửa" href='<%# "/SuaNguoiDung.aspx?userid="+ Eval("UserId") %>'></a>
                                <span style="padding-left: 5px"></span>
                                <asp:LinkButton CssClass='<%#Eval("Status").ToString()=="1" ? "glyphicon glyphicon-remove-circle" : "glyphicon glyphicon-ok-circle"%>'
                                    runat="server" ID="aDel" title='<%#Eval("Status").ToString()=="1" ? "Khóa" : "Mở"%>' 
                                    CommandName="deluser" CommandArgument='<%#Eval("UserId")%>'></asp:LinkButton>
                            </div>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <PagerStyle Position="Bottom" AlwaysVisible="True" Mode="NumericPages"></PagerStyle>
            <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" EnableRowHoverStyle="true">
                <Scrolling AllowScroll="True"></Scrolling>
                <Selecting AllowRowSelect="True"></Selecting>
                <ClientEvents OnGridCreated="GridCreated"></ClientEvents>
            </ClientSettings>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    </div>
</asp:Content>
